//
//  ByToRepairVC.m
//  hutouben_ios
//
//  Created by justiOS on 16/12/1.
//  Copyright © 2016年 mc. All rights reserved.
//

#import "ByToRepairVC.h"
// view
#import "ByTextView.h"
@interface ByToRepairVC ()
{
    UITextField *_addressTF;                  // 地址
    UITextField *_mobleTF;                    // 电话
    UITextField *_carTepyTF;                  // 车型
    UITextField *_tepyTF;                     // 报修类型
    ByTextView *_detailTV;                    // 详情
}
@end

@implementation ByToRepairVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HTB_BG_GRAY;
    [self creatViews];
}

- (void)creatViews {
    
    // 地点
    _addressTF = [[UITextField alloc] initWithFrame:CGRectMake(30, 35, SCREEN_WIDTH - 60, 40)];
    _addressTF.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
    _addressTF.leftViewMode = UITextFieldViewModeAlways;
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
    label1.text = @"地点:";
    label1.font = FONT(14);
    label1.textAlignment = NSTextAlignmentCenter;
    _addressTF.leftView = label1;
    _addressTF.font = FONT(14);
    _addressTF.placeholder = @"请输入车辆故障地点或获得定位";
    _addressTF.rightViewMode = UITextFieldViewModeAlways;
    UIImageView *addressimage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    addressimage.userInteractionEnabled = YES;
    UITapGestureRecognizer *addressTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(locationTapAction:)];
    [addressimage addGestureRecognizer:addressTap];
    addressimage.image = [UIImage imageWithColor:HTB_THEME_COLOR];
    _addressTF.rightView = addressimage;
    [self.view addSubview:_addressTF];
    
    // 类型
    _tepyTF = [[UITextField alloc] initWithFrame:CGRectMake(30, _addressTF.bottom + 15, SCREEN_WIDTH - 60, 40)];
    _tepyTF.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
    _tepyTF.enabled = NO;
    _tepyTF.leftViewMode = UITextFieldViewModeAlways;
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
    label2.text = @"类型:";
    label2.font = FONT(14);
    label2.textAlignment = NSTextAlignmentCenter;
    _tepyTF.leftView = label2;
    _tepyTF.font = FONT(14);
    _tepyTF.placeholder = @"请点击选择类型";
    UIImageView *tepyimage = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 70, _addressTF.bottom + 15, 40, 40)];
    tepyimage.userInteractionEnabled = YES;
    tepyimage.image = [UIImage imageWithColor:HTB_THEME_COLOR];
    UITapGestureRecognizer *tepyTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tepyTapAction:)];
    [tepyimage addGestureRecognizer:tepyTap];
    [self.view addSubview:_tepyTF];
    [self.view addSubview:tepyimage];

    
    
    // 电话
    _mobleTF = [[UITextField alloc] initWithFrame:CGRectMake(30, _tepyTF.bottom + 15, SCREEN_WIDTH - 60, 40)];
    _mobleTF.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
    _mobleTF.leftViewMode = UITextFieldViewModeAlways;
    UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
    label3.text = @"电话:";
    label3.font = FONT(14);
    label3.textAlignment = NSTextAlignmentCenter;
    _mobleTF.leftView = label3;
    _mobleTF.font = FONT(14);
    _mobleTF.placeholder = @"请输入联系人电话";
    [self.view addSubview:_mobleTF];
    
    // 车型
    _carTepyTF = [[UITextField alloc] initWithFrame:CGRectMake(30, _mobleTF.bottom + 15, SCREEN_WIDTH - 60, 40)];
    _carTepyTF.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
    _carTepyTF.leftViewMode = UITextFieldViewModeAlways;
    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
    label4.text = @"车型:";
    label4.font = FONT(14);
    label4.textAlignment = NSTextAlignmentCenter;
    _carTepyTF.leftView = label4;
    _carTepyTF.font = FONT(14);
    _carTepyTF.placeholder = @"请填写车型";
    [self.view addSubview:_carTepyTF];
    
    
    // 详情
    UIView *bgview = [[UIView alloc] initWithFrame:CGRectMake(30, _carTepyTF.bottom + 15, SCREEN_WIDTH - 60, 80)];
    bgview.backgroundColor = [UIColor colorWithWhite:0.85 alpha:1];
    [self.view addSubview:bgview];
    _detailTV = [[ByTextView alloc] initWithFrame:CGRectMake(75, 5, SCREEN_WIDTH - 60 - 75, 70)];
    _detailTV.backgroundColor = [UIColor clearColor];
    _detailTV.placeholder = @"请输入您的故障详细描述";
    [bgview addSubview:_detailTV];
    
    UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, 65, 30)];
    label5.text = @"详情描述:";
    label5.font = FONT(14);
    label5.textAlignment = NSTextAlignmentCenter;
    [bgview addSubview:label5];

    
    UIButton *repairButton = [UIButton buttonWithType:UIButtonTypeCustom];
    CGFloat y;
    y = (SCREEN_HEIGHT - 64 - bgview.bottom - 40)/2;
    repairButton.frame = CGRectMake(30, bgview.bottom + y, SCREEN_WIDTH - 60, 40);
    [repairButton addTarget:self action:@selector(toRepairAction:) forControlEvents:UIControlEventTouchUpInside];
    repairButton.backgroundColor = HTB_THEME_COLOR;
    repairButton.titleLabel.font = FONT(14);
    [repairButton setTitle:@"立即报修" forState:UIControlStateNormal];
    [self.view addSubview:repairButton];
}


#pragma mark 点击事件
- (void)locationTapAction:(UITapGestureRecognizer *)tap {
    [ByCoreToolAlert showOnlyText:@"定位"];
}

- (void)tepyTapAction:(UITapGestureRecognizer *)tap {
    [ByCoreToolAlert showOnlyText:@"选择类型"];
}

- (void)toRepairAction:(UIButton *)button {
    [ByCoreToolAlert showOnlyText:@"报修"];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
